{{--@extends ('shop-backend::layout')--}}

{{--@section ('title','活动列表')--}}

{{--@section ('breadcrumbs')--}}
    {{--<h2>活动列表</h2>--}}

    {{--<ol class="breadcrumb">--}}
        {{--<li><i class="fa fa-dashboard"></i> 首页</li>--}}
        {{--<li>{!! link_to_route('admin.shop.list.store', '门店') !!}</li>--}}
        {{--<li class="active">活动列表</li>--}}
    {{--</ol>--}}
{{--@stop--}}
{{--@section('after-styles-end')--}}
    {!! Html::style(env("APP_URL").'/assets/backend/libs/datepicker/bootstrap-datetimepicker.min.css') !!}
{{--@stop--}}
{{--@section('content')--}}
    <div class="ibox float-e-margins">
        <div class="ibox-content" style="display: block;">
            <div class="row">
                <div class="col-md-10">
                    <div class="btn-group">
                        <a class="btn btn-primary " href="{{route('admin.shop.list.activity.curd')}}">添加活动</a>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <form method="get" action="">
                        <div class="col-sm-3" style="padding-left: 0">
                            <div class="input-group date form_datetime" data-date-format="yyyy-mm-dd">
                                    <span class="input-group-addon" style="cursor: pointer">
                                        <i class="fa fa-calendar"></i></span>
                                <input type="text" class="form-control inline" name="stime"
                                       value="{{request('stime')}}" placeholder="开始时间 " readonly>
                                <span class="add-on"><i class="icon-th"></i></span>
                            </div>
                        </div>
                        <div class="col-sm-3" style="padding-left: 0">
                            <div class="input-group date form_datetime" data-date-format="yyyy-mm-dd">
                                    <span class="input-group-addon" style="cursor: pointer">
                                        <i class="fa fa-calendar"></i></span>
                                <input type="text" class="form-control" name="etime" value="{{request('etime')}}" placeholder="截止" readonly>
                                <span class="add-on"><i class="icon-th"></i></span>
                            </div>
                        </div>
                        <div class="col-sm-3" style="padding-left: 0">
                            <div class="input-group search_text">
                                <input type="text" name="name" placeholder="活动名称" value="{{!empty(request('name'))?request('name'):''}}" class=" form-control">
                                <span class="input-group-btn">
                                    <button type="submit" class="btn btn-primary">查找</button>
                                </span>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <table class="table table-striped table-bordered table-hover">
                <thead>
                    <tr>
                        <th>活动名称</th>
                        <th>活动链接</th>
                        <th>活动有效期</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    @if (!empty($data))
                        @foreach ($data as $v)
                            <tr>
                                <td>{!! $v->name !!}</td>
                                <td>{!! $v->url !!}</td>
                                <td>{!! date('Y-m-d', $v->act_starttime) !!}
                                    - {!! date('Y-m-d', $v->act_endtime) !!}</td>
                                <td>
                                    <a href="{!!route('admin.shop.list.activity.curd', ['id' => $v->id])!!}" class="btn btn-xs btn-primary"><i class="fa fa-pencil" data-toggle="tooltip" data-placement="top" title="" data-original-title="编辑"></i></a>
                                    <a href="{!!route('admin.shop.list.activity.select', ['id' => $v->id])!!}" class="btn btn-xs btn-info"><i class="fa fa-refresh" data-toggle="tooltip" data-placement="top" title="" data-original-title="勾选多门店"></i></a>
                                    <a class="btn btn-xs btn-danger" style="cursor:pointer;" onclick="del_act({!!$v -> id!!});"><i class="fa fa-trash" data-toggle="tooltip" data-placement="top" title="" data-original-title="删除"></i></a>
                                </td>
                            </tr>
                        @endforeach
                    @endif
                    <meta name="csrf-token" content="{{ csrf_token() }}">
                </tbody>
            </table>
            {!! $data->render() !!}
            <div class="pull-right">
            </div>
            <div class="clearfix"></div>
        </div>
    </div>
{{--@stop--}}
{{--@section('after-scripts-end')--}}
    {!! Html::script(env("APP_URL").'/assets/backend/libs/datepicker/bootstrap-datetimepicker.js') !!}
    {!! Html::script(env("APP_URL").'/assets/backend/libs/datepicker/bootstrap-datetimepicker.zh-CN.js') !!}
    <script>
    function del_act(id) {

        swal({
            title: "确定删除此项？会影响门店列表功能",
            text: "",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "删除",
            cancelButtonText: "取消",
            closeOnConfirm: false,
        }, function () {
            $.ajax({
                type: 'POST',
                url: "{!!route('store.ajax.del')!!}",
                data: {'id': id, 'type': 'act'},
                dataType: 'json',
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                },
                success: function (data) {
                    if (200 == data.code) {
                        swal({
                            title: "删除成功！",
                            text: "",
                            type: "success"
                        }, function () {
                            location = '{{route('admin.shop.list.activity')}}';
                        });
                    } else {
                        swal("删除失败！", data.message, 'warning');
                    }
                }
            });

        });

        {{--if (confirm('确定删除此项？会影响门店列表功能')) {--}}
            {{--$.ajax({--}}
                {{--type: 'POST',--}}
                {{--url: "{!!route('store.ajax.del')!!}",--}}
                {{--data: {'id': id, 'type': 'act'},--}}
                {{--dataType: 'json',--}}
                {{--headers: {--}}
                    {{--'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')--}}
                {{--},--}}
                {{--success: function (data) {--}}
                    {{--if (200 == data.code) {--}}
                        {{--swal({--}}
                            {{--title: "删除成功！",--}}
                            {{--text: "",--}}
                            {{--type: "success"--}}
                        {{--}, function () {--}}
                            {{--location = '{{route('admin.shop.list.activity')}}';--}}
                        {{--});--}}
                    {{--} else {--}}
                        {{--swal("删除失败！", data.message, 'warning');--}}
                    {{--}--}}
                {{--}--}}
            {{--});--}}
        {{--}--}}
    }

    $('.form_datetime').datetimepicker({
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1,
        minuteStep: 1
    });
</script>
{{--@stop--}}